//
//  JCComyCellView.swift
//  JCNewsForMac
//
//  Created by ifly on 1/8/18.
//  Copyright © 2018年 Ismail. All rights reserved.
//

import Cocoa

class JCComyCellView: NSView {

    override func draw(_ dirtyRect: NSRect) {
        super.draw(dirtyRect)

        // Drawing code here.
    }
    
    
    private var jcTitleText = NSTextField()
    private var jcTimeText = NSTextField()
    
    private var jcData = JCCompany()
    
    var jcTureAction:((_ cid:String)->Void)?
    var jcFalseAction:((_ cid:String)->Void)?
    
    
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        
        setUI()
    }
    
    required init?(coder decoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setUI() -> Void {
        
        addSubview(jcTitleText)
        addSubview(jcTimeText)
        
        jcTitleText.isEditable = false
        jcTitleText.isBordered = false
        jcTitleText.font = NSFont.systemFont(ofSize: 16)
        jcTitleText.backgroundColor = NSColor.clear
        
        jcTimeText.isEditable = false
        jcTimeText.isBordered = false
        jcTimeText.font = NSFont.systemFont(ofSize: 14)
        jcTimeText.textColor = NSColor.gray
        jcTimeText.backgroundColor = NSColor.clear
        
        jcTitleText.snp.makeConstraints { (make) in
            make.left.equalTo(self).offset(10)
            make.top.equalTo(self).offset(5)
            make.right.equalTo(self.snp.rightMargin).offset(-10)
            make.height.equalTo(30)
        }
        
        jcTimeText.snp.makeConstraints { (make) in
            make.left.equalTo(self).offset(10)
            make.top.equalTo(self.jcTitleText.snp.bottom).offset(0)
            make.right.equalTo(self.snp.rightMargin).offset(-10)
            make.height.equalTo(25)
        }
    }
    
    func setData(_ data:JCCompany) -> Void {
        
        self.jcData = data
        
        jcTitleText.stringValue = "企业名称: " + data.company_name
        jcTimeText.stringValue = "提交时间：" + data.company_time
        
    }
    
    @objc private  func accFunc(){
        if (jcTureAction != nil) {
            self.jcTureAction!(self.jcData.company_id)
        }
    }
    
    @objc private  func faseFunc(){
        if (jcFalseAction != nil) {
            self.jcFalseAction!(self.jcData.company_id)
        }
        
    }
    
    
    
}
